package org.example.controller;

import org.example.factories.CloudService;
import org.springframework.core.io.support.SpringFactoriesLoader;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class FactoryController {
    @GetMapping("/sendMsgV3")
    public String sendMsgV3(String msg) throws Exception{
        List<CloudService> smsServices= SpringFactoriesLoader.loadFactories(CloudService.class, CloudService.class.getClassLoader());
        for(CloudService smsService : smsServices){
            smsService.sendMessage(msg);
        }
        return "success";
    }
}
